function [PQ] = SS_PruneMissingTasks(PQ, sensor1TargetOrder, sensor2TargetOrder)
%SS_PruneMissingTasks prunes missing targets.
% Prune targets that have dissappeared (from either sensor)
s1rows = size(sensor1TargetOrder, 1);
s1cols = size(sensor1TargetOrder, 2);
s2rows = size(sensor2TargetOrder, 1);
s2cols = size(sensor2TargetOrder, 2);

taskNr = 1;
while 1
  Task = PQ_Fetch_Task(PQ, taskNr, 0);
  % Check in sensor 1 target list
  found = 0;
  for a = 1:s1rows
    for b = 1:s1cols
      if sensor1TargetOrder(a, b) > 0
        if (Task.id == sensor1TargetOrder(a, b))
          found = 1;
          break;
        end
      end
    end
  end
  if found
    found = 0;
    for a = 1:s2rows
      for b = 1:s2cols
        if sensor2TargetOrder(a, b) > 0
          if (Task.id == sensor2TargetOrder(a, b))
            found = 1;
            break;
          end
        end
      end
    end
  end
  
  if ~found
    % delete the task from the queue
    PQ = PQ_Remove_Task(PQ, taskNr);
  else
    taskNr = taskNr + 1;
  end
  
  if taskNr > PQ_Size(PQ)
    break;
  end
end
end